using System;
using CommunityToolkit.Mvvm.Input;

namespace SchoolApp_Material.ViewModels;

public class StudentViewModel:ViewModelBase
{
    public Action<StudentViewModel> EditAction;
    public Action<StudentViewModel> DelAction;

    #region 属性

    private int _id;

    public int Id
    {
        get => _id;
        set => SetProperty(ref _id, value);
    }

    private string _code;

    public string Code
    {
        get => _code;
        set => SetProperty(ref _code, value);
    }

    private string _name;

    public string Name
    {
        get => _name;
        set => SetProperty(ref _name, value);
    }

    private string _sex;

    public string Sex
    {
        get => _sex;
        set => SetProperty(ref _sex, value);
    }

    private string _birthYear;

    public string BirthYear
    {
        get => _birthYear;
        set => SetProperty(ref _birthYear, value);
    }

    private string _formYear;

    public string FormYear
    {
        get => _formYear;
        set => SetProperty(ref _formYear, value);
    }

    private string _formCode;

    public string FormCode
    {
        get => _formCode;
        set => SetProperty(ref _formCode, value);
    }

    private string _createOperatorCode;

    public string CreateOperatorCode
    {
        get => _createOperatorCode;
        set => SetProperty(ref _createOperatorCode, value);
    }

    private string _createOperatorName;

    public string CreateOperatorName
    {
        get => _createOperatorName;
        set => SetProperty(ref _createOperatorName, value);
    }

    private DateTime _createTime;

    public DateTime CreateTime
    {
        get => _createTime;
        set => SetProperty(ref _createTime, value);
    }

    #endregion

    #region 命令

    #region 编辑

    private RelayCommand _editCmd;

    public RelayCommand EditCmd =>
        _editCmd ??= new RelayCommand(ExecuteEditCmd);

    private void ExecuteEditCmd()
    {
        EditAction?.Invoke(this);
    }

    #endregion

    #region 删除

    private RelayCommand _delCmd;

    public RelayCommand DelCmd =>
        _delCmd ??= new RelayCommand(ExecuteDelCmd);

    private void ExecuteDelCmd()
    {
        DelAction.Invoke(this);
    }

    #endregion

    #endregion
}